home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_429 / uedit-stuff / delete < prev    next >
Text File  |  1992-05-06  |  15KB  |  363 lines

  1. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. *** Uedit scratch-delete functions which remember the last eight deletes
  3. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4.  
  5. n28 contains the number of the buffer that holds the newest cut.  This gets
  6. bumped by virtual-kp7 just before the cut is made, if it isn't merging with
  7. the last one.  To change the range of buffers that is used to store cut
  8. pieces (currently 80 to 87), you only need to change three commands:  the
  9. ring rotating commands lAmiga-kp4 and lAmiga-kp6, and the general deleting
  10. engine virtual-kp7, at the lines where the comment says "Bounds".  If you
  11. want to change the n-vars used, you'll have to change lots of commands.
  12.  
  13. n27 is the buffer the last cut was made in, or -1 if any paste has been made
  14. since the last cut.  It is -2 after ctl-kp0 if it was nonnegative before,
  15. which means don't merge the next cut, but don't allow operations that work on
  16. the last paste either (lamiga-kp1, lamiga-kp0).
  17.  
  18. General scratch deleter - decide whether to merge, then move locA-locB to ring
  19. <virtual-kp7:   if (eqnum(n27, curfile))  .. shall we merge? last cut was here
  20.                     if (not eqloc(curfile, locA, mouseloc))     .. mouseloc is
  21.                         if (not eqloc(curfile, locB, mouseloc)) ..   old locB
  22.                             equatenum(n27, -2)                  .. no
  23.                 equatenum(n54, n28)      .. ** for virtual-kp4 split display
  24.                 if (not eqnum(n27, curfile)) {                  .. un-merge:
  25.                     if (genum(80, n28)) equatenum(n28, 87)      .. Bounds
  26.                     else decnum(n28)
  27.                     freeBuf(buf[n28])
  28.                 } else if (gtnum(80, n28)) equatenum(n28, 87)   .. Bounds
  29.                 if (eqloc(curfile, mouseloc, locA))         .. front or back?
  30.                     insertrgn(buf[n28], efile, curfile, loc)
  31.                 else insertrgn(buf[n28], sfile, curfile, loc)
  32.                 equateloc(buf[n28], spage, sfile)               .. cosmetic
  33.                 clearrgn(curfile, loc)  .. mustn't forget to actually delete!
  34.                 if (genum(n54, 80))             .. ** Bounds
  35.                     runkey(virtual-kp4)         .. ** update split window
  36.                 equatenum(n27, curfile)
  37. >
  38. Those lines marked with ** can be removed for speed if desired.  They
  39. cause a split window made with lamiga-1 to be updated in real time as you
  40. delete things.
  41.  
  42. Show top of delete ring in split window
  43. <lamiga-1:      equatenum(n54, curfile)
  44.                 if (not eqnum(curfile, n28)) if (not gotosplit(buf[n28])) {
  45.                     splitwindow(buf[n28], splitsize)
  46.                     gotosplit(buf[n54])  .. not curfile unless press it again
  47.                 }
  48.                 putmsg("Use lAmiga-kp4 and lAmiga-kp6 to rotate ring")
  49. >
  50.  
  51. *** HERE'S THE SIMPLE VERSION that leaves the split window curfile ***
  52. Show top of delete ring in split window
  53. .. <lamiga-1:   if (not eqnum(curfile, n28)) if (not gotosplit(buf[n28]))
  54.                     splitwindow(buf[n28], splitsize)
  55.                 putmsg("Use lAmiga-kp4 and lAmiga-kp6 to rotate ring")
  56. >
  57.  
  58. Push back newest entry on scratch delete ring
  59. <lamiga-kp4:    equatenum(n54, n28)
  60.                 if (genum(n28, 87)) equatenum(n28, 80)          .. Bounds
  61.                 else incnum(n28)
  62.                 runkey(virtual-kp4)
  63. >
  64.  
  65. Pull forward oldest entry on scratch delete ring
  66. <lamiga-kp6:    equatenum(n54, n28)
  67.                 if (genum(80, n28)) equatenum(n28, 87)          .. Bounds
  68.                 else decnum(n28)
  69.                 runkey(virtual-kp4)
  70. >
  71.  
  72. Display correct buffer in top-of-delete-ring split window
  73. <virtual-kp4:   if (eqnum(curfile, n54)) editbuf(buf[n28])
  74.                 else {
  75.                     equatenum(n53, curfile)
  76.                     if (gotosplit(buf[n54])) {
  77.                         editbuf(buf[n28])
  78.                         gotosplit(buf[n53])
  79.                     }
  80.                 }
  81. >
  82.  
  83. Undo last paste (kp0), hopefully only when it was just done
  84. <lamiga-kp0:    if (not eqnum(n27, -1)) {
  85.                     putmsg("No paste since last cut")
  86.                     returnfalse
  87.                 }
  88.                 if (not eqloc(curfile, atcursor, locB)) {
  89.                     putmsg("Can't un-paste -- wrong location")
  90.                     returnfalse
  91.                 }
  92.                 clearrgn(curfile, loc)
  93.                 equatenum(n27, curfile)
  94. >
  95.  
  96. Go to location of last scratch delete or undo
  97. <lamiga-kp5:    movecursor(curfile, locB) >
  98.  
  99. Go to top end of last scratch undo, or maybe anywhere
  100. <lamiga-kp8:    if (not eqnum(n27, -1)) putmsg("No paste since last cut")
  101.                 else movecursor(curfile, locA)
  102. >
  103.  
  104. Undo latest scratch delete, inserting at cursor, marking with loc
  105. <normal-kp0:    if (eqnum(n28, 0)) return               .. no cut since start!
  106.                 equateloc(curfile, locA, atcursor)
  107.                 if (eqloc(curfile, atcursor, sfile)) {
  108.                     insertrgn(curfile, sfile, buf[n28], all)
  109.                     equateloc(curfile, locA, sfile)
  110.                 } else {
  111.                     equateloc(curfile, locA, atcursor)
  112.                     decloc(curfile, locA)
  113.                     insertRgn(curFile,atCursor,buf[n28],all)
  114.                     incloc(curfile, locA)
  115.                 }
  116.                 equateloc(curfile, locB, atcursor)
  117.                 equatenum(n27, -1)
  118.                 if (thiskey)
  119.                     if (eqloc(curfile, atcursor, spage)) {  .. don't you hate it
  120.                         vscroll(atcursor)                   .. when the pasted-in
  121.                         updatedisplay                       .. text is offscreen?
  122.                     }
  123. >
  124.  
  125. Set search string, using text of last cut
  126. <shftaltctl-f7: freebuf(buf49)
  127.                 insertrgn(buf49, sfile, buf[n28], all)
  128.                 putmsg("Input search string:")
  129.                 inputstring(buf49)
  130.                 setsearch(buf49)
  131.                 runkey(normal-f9)
  132. >
  133.  
  134. Replace last paste with older cut, hopefully only when it was just done
  135. <lamiga-kp1:    if (runkey(lamiga-kp0)) {
  136.                     runkey(lamiga-kp4)
  137.                     runkey(normal-kp0)
  138.                 }
  139. >
  140.  
  141. Prevent next delete from merging with the previous one
  142. <ctl-kp0:       if (genum(n27, 0)) equatenum(n27, -2)  >
  143.  
  144. Delete word left, storing it in Undo buffer
  145. <normal-kp7:    equateloc(curfile, mouseloc, locB)
  146.                 equateloc(curfile, locB, atcursor)
  147.                 movecursor(curfile, sword)
  148.                 equateloc(curfile, locA, atcursor)
  149.                 runkey(virtual-kp7)
  150. >
  151.  
  152. Delete word right, storing it in Undo buffer
  153. <normal-kp9:    equateloc(curfile, mouseloc, locB)
  154.                 equateloc(curfile, locA, atcursor)
  155.                 movecursor(curfile, eword)
  156.                 equateloc(curfile, locB, atcursor)
  157.                 runkey(virtual-kp7)
  158.  
  159. Delete char to left of cursor, storing it in Undo buffer
  160. <shft-kp7:      equateloc(curfile, mouseloc, locB)
  161.                 equateloc(curfile, locB, atcursor)
  162.                 movecursor(curfile, schar)
  163.                 equateloc(curfile, locA, atcursor)
  164.                 runkey(virtual-kp7)
  165. >
  166.  
  167. Delete char under cursor, storing it in Undo buffer
  168. <shft-kp9:      equateloc(curfile, mouseloc, locB)
  169.                 equateloc(curfile, locA, atcursor)
  170.                 movecursor(curfile, echar)
  171.                 equateloc(curfile, locB, atcursor)
  172.                 runkey(virtual-kp7)
  173.  
  174. Delete to start of line, storing it in Undo buffer
  175. <alt-kp7:       if (is(curFile,sLine)) runKey(shft-kp7)
  176.                 else {
  177.                     equateloc(curfile, mouseloc, locB)
  178.                     equateloc(curfile, locB, atcursor)
  179.                     movecursor(curfile, sline)
  180.                     equateloc(curfile, locA, atcursor)
  181.                     runkey(virtual-kp7)
  182.                 }
  183. >
  184.  
  185. Delete to end of line, storing it in Undo buffer
  186. <alt-kp9:       if (is(curFile,eLine)) runKey(shft-kp9)
  187.                 else {
  188.                     equateloc(curfile, mouseloc, locB)
  189.                     equateloc(curfile, locA, atcursor)
  190.                     movecursor(curfile, eline)
  191.                     equateloc(curfile, locB, atcursor)
  192.                     runkey(virtual-kp7)
  193.                 }
  194. >
  195.  
  196.   Personally, I don't use these next two, they're too accident-prone.
  197.  
  198. Delete from cursor to start of window, storing it in Undo buffer
  199. <ctl-kp7:       equateloc(curfile, mouseloc, locB)
  200.                 equateloc(curfile, locB, atcursor)
  201.                 movecursor(curfile, spage)
  202.                 equateloc(curfile, locA, atcursor)
  203.                 runkey(virtual-kp7)
  204.                 vscroll(atcursor)
  205.                 updatedisplay
  206. >
  207.  
  208. Delete from cursor to end of window, storing it in Undo buffer
  209. <ctl-kp9:       equateloc(curfile, mouseloc, locB)
  210.                 equateloc(curfile, locA, atcursor)
  211.                 movecursor(curfile, epage)
  212.                 equateloc(curfile, locB, atcursor)
  213.                 runkey(virtual-kp7)
  214.                 vscroll(atcursor)
  215.                 updatedisplay
  216. >
  217.  
  218. Delete cursor line
  219. <virtual-x:     equateLoc(curFile, mouseLoc, locB)
  220.                 if (not is(curFile,sLine)) moveCursor(curFile,sLine)
  221.                 equateloc(curfile, locA, atcursor)
  222.                 if (not is(curFile,eLine)) moveCursor(curFile,eLine)
  223.                 moveCursor(curFile,eChar)
  224.                 equateLoc(curFile,locB,atCursor)
  225.                 runkey(virtual-kp7)
  226. >
  227.  
  228. (redundant with standard config)
  229. UNDO newest scratch delete, inserting at cursor
  230. <alt-kp0:       runKey(normal-kp0) >
  231. UNDO newest scratch delete, inserting at cursor
  232. <shft-kp0:      runKey(normal-kp0) >
  233.  
  234. Delete cursor line, storing it in Undo buffer.  (See keypad-0/7/9.)
  235. <ctl-d:   runKey(virtual-x) >
  236.  
  237. Delete line above cursor line
  238. <ctl-del:  locToCol(curfile, n50, atCursor)
  239.            if (moveCursor(curFile,upLine)) {
  240.                runKey(virtual-x)                .. this deletes the line
  241.                colToLoc(curfile, atCursor, n50)
  242.            }
  243. >
  244.  
  245. Delete line below cursor line
  246. <ctl-bs: locToCol(curfile, n50, atcursor)
  247.          if (moveCursor(curFile,downLine)) {
  248.              runKey(virtual-x)          .. this deletes the line
  249.              moveCursor(curFile,upLine)
  250.              colToLoc(curfile, atCursor, n50)
  251.          }
  252. >
  253.  
  254. Delete from cursor back to most recent occurence of character
  255. <lamiga-kp7:    putmsg("What character should mark the start of the delete?")
  256.                 getchar(n0)
  257.                 equateloc(curfile, mouseloc, locB)
  258.                 equateloc(curfile, locB, atcursor)
  259.                 decloc(curfile, atcursor) .. skip first character
  260.                 equatenum(n1, -1)
  261.                 if (runkey(virtual-/)) {
  262.                     movecursor(curfile, echar)
  263.                     equateloc(curfile, locA, atcursor)
  264.                     runkey(virtual-kp7)
  265.                     putmsg(" ")
  266.                 } else {
  267.                     movecursor(curfile, locB)
  268.                     equateloc(curfile, locB, mouseloc)
  269.                     putmsg("Not found.")
  270.                 }
  271.                 setsearch(buf53)
  272. >
  273.  
  274. Delete from cursor to next occurence of a given character
  275. <lamiga-kp9:    putmsg("What character should mark the end of the delete?")
  276.                 getchar(n0)
  277.                 equateloc(curfile, mouseloc, locB)
  278.                 equateloc(curfile, locB, atcursor)
  279.                 equatenum(n1, 1)
  280.                 if (runkey(virtual-/)) {
  281.                     equateloc(curfile, locA, locB)  .. swap ends
  282.                     equateloc(curfile, locB, atcursor)
  283.                     runkey(virtual-kp7)
  284.                     putmsg(" ")
  285.                 } else {
  286.                     equateloc(curfile, locB, mouseloc)
  287.                     putmsg("Not found.")
  288.                 }
  289.                 setsearch(buf53)
  290. >
  291.  
  292. Search for single char n0 in direction n1, trashing locA, using your searchCaps
  293. <virtual-/:     freebuf(buf54)
  294.                 insertchar(buf54, "\\")
  295.                 insertchar(buf54, n0)
  296.                 freebuf(buf53)
  297.                 getsearch(buf53)
  298.                 setsearch(buf54)
  299.                 search(curfile, locA, locA, n1)  .. don't care which
  300. > returns true or false depending on search             end locA ends up on
  301.  
  302. Extend the last scratch delete to cursor in either direction
  303. <lamiga-kp3:    if (gtloc(curfile, atcursor, locB)) {
  304.                     equateloc(curfile, locA, locB)
  305.                     equateloc(curfile, locB, atcursor)
  306.                     equateloc(curfile, mouseloc, locA)
  307.                 } else {
  308.                     equateloc(curfile, locA, atcursor)
  309.                     equateloc(curfile, mouseloc, locB)
  310.                 }
  311.                 runkey(virtual-kp7)
  312. >
  313.  
  314. Delete back to end of indent whitespace
  315. <shftalt-kp7:   loctocol(curfile, n51, atcursor)
  316.                 if (not runkey(ctl-[)) returnfalse      .. ctl-[ is missing!
  317.                 if (gtnum(n51, n50)) {
  318.                     equateloc(curfile, mouseloc, locB)
  319.                     equateloc(curfile, locA, atcursor)
  320.                     coltoloc(curfile, atcursor, n51)
  321.                     equateloc(curfile, locB, atcursor)
  322.                     runkey(virtual-kp7)
  323.                 } else coltoloc(curfile, atcursor, n51)
  324. >
  325.  
  326. Delete from cursor to start of paragraph (last blank line)
  327. <shftctl-kp7:   equateloc(curfile, mouseloc, locB)
  328.                 equateloc(curfile, locB, atcursor)
  329.                 while (decloc(curfile, atcursor))
  330.                     if (is(curfile, whitespace)) goto label (47)
  331.             label (47)
  332.                 while (movecursor(curfile, upline))
  333.                     if (is(curfile, blankline)) {
  334.                         movecursor(curfile, downline)
  335.                         if (not is(curfile, sline)) movecursor(curfile, sline)
  336.                         goto label (1)
  337.                     }
  338.                 movecursor(curfile, sfile)
  339.             label (1)
  340.                 equateloc(curfile, locA, atcursor)
  341.                 runkey(virtual-kp7)
  342. >
  343.  
  344. Delete from cursor to end of paragraph (next blank line)
  345. <shftctl-kp9:   equateloc(curfile, mouseloc, locB)
  346.                 equateloc(curfile, locA, atcursor)
  347.                 while (incloc(curfile, atcursor))
  348.                     if (is(curfile, whitespace)) goto label (47)
  349.             label (47)
  350.                 while (movecursor(curfile, downline))
  351.                     if (is(curfile, blankline)) {
  352.                         if (not is(curfile, sline)) movecursor(curfile, sline)
  353.                         movecursor(curfile, schar)
  354.                         goto label (1)
  355.                     }
  356.                 movecursor(curfile, efile)
  357.             label (1)
  358.                 equateloc(curfile, locB, atcursor)
  359.                 runkey(virtual-kp7)
  360. >
  361.